package kr.ac.kaist.ysproject;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;

public class SettingMyProfileActivity extends Activity {
	
	Activity activity = this;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setting_my_profile);
        
        
        
        /***********************************************************************
    	 * 
    	 * 
    	 * 자기 사진 설정
    	 * 
    	 * 
    	 ***********************************************************************/
        
        
        
        
        
        
        
        /***********************************************************************
    	 * 
    	 * 
    	 * 자기 이름 설정
    	 * 
    	 * 
    	 ***********************************************************************/
        // 이름레이어 선택 시, 편집모드로 전환
        ((LinearLayout)findViewById(R.id.linearLayoutMyName)).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				((TextView) findViewById(R.id.textViewMyName)).setVisibility(View.GONE);
				((EditText) findViewById(R.id.editTextMyName)).setText(((TextView) findViewById(R.id.textViewMyName)).getText());
				((EditText) findViewById(R.id.editTextMyName)).setVisibility(View.VISIBLE);
				((EditText) findViewById(R.id.editTextMyName)).requestFocus();
			}
		});
        
        
        
        
        /***********************************************************************
    	 * 
    	 * 
    	 * 자기 휴대폰 번호 가져오기
    	 * 
    	 * 
    	 ***********************************************************************/
        TelephonyManager telManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); 
        ((TextView)findViewById(R.id.textViewMyPhone)).setText(telManager.getLine1Number());
        
//      Toast.makeText(activity, "내번호 : ", Toast.LENGTH_SHORT).show();
        
    }
    
    
    
    
    /***********************************************************************
	 * 
	 * 
	 * 화면 터치 이벤트
	 * 
	 * 
	 ***********************************************************************/
    @Override
    public boolean onTouchEvent(MotionEvent event) {
    	
    	// 이름을 뷰모드로 전환
    	((EditText) findViewById(R.id.editTextMyName)).setVisibility(View.GONE);
		((TextView) findViewById(R.id.textViewMyName)).setText(((EditText) findViewById(R.id.editTextMyName)).getText());
		((TextView) findViewById(R.id.textViewMyName)).setVisibility(View.VISIBLE);
    	
    	return super.onTouchEvent(event);
    }
}
